const Sequelize = require("sequelize");
const seq = require("../db/index");

const UsersModel = seq.define(
  "Users",
  {
    //用户id
    userId: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true,
      allowNull: false,
    },
    // 用户名
    name: {
      type: Sequelize.STRING(50),
      allowNull: false,
    },
    //头像
    avatar: {
      type: Sequelize.STRING(255),
    },
    //年龄
    age: {
      type: Sequelize.INTEGER,
    },
    //性别
    sex: {
      type: Sequelize.ENUM("男", "女"),
      allowNull: false,
    },
    // 手机号
    phone: {
      type: Sequelize.STRING(15),
      allowNull: false,
      unique: true,
    },
    // 角色
    roles: {
      type: Sequelize.ENUM("user", "seller", "admin"),
      allowNull: false,
    },
    //是否同意约定服务内容
    agree: {
      type: Sequelize.BOOLEAN,
      defaultValue: false,
    },
    //是否同意违约条款
    defaultClauses: {
      type: Sequelize.BOOLEAN,
      defaultValue: false,
    },
    // 能标签
    skillsLabel: {
      type: Sequelize.JSON,
    },
    // 服务内容
    serviceContent: {
      type: Sequelize.TEXT,
    },
    // 服务者等级（如萌新跨越者、星级跨越者）
    level: {
      type: Sequelize.STRING(50),
    },
    //信用评分
    creditRating: {
      type: Sequelize.FLOAT,
      defaultValue: 0,
    },
    // 身份证正面图片 URL
    idCardPositiveImage: {
      type: Sequelize.STRING(255),
    },
    // 身份证反面图片 URL
    idCardNegativeImage: {
      type: Sequelize.STRING(255),
    },
    // 	身份证有效期
    idCardTime: {
      type: Sequelize.DATE,
    },
    // 	身份证姓名
    idCardName: {
      type: Sequelize.STRING(50),
    },
    // 是否实名认证
    isAuthentication: {
      type: Sequelize.BOOLEAN,
      defaultValue: false,
    },
    // 用户状态（0：封禁，1：正常，2：违规）
    userStatus: {
      type: Sequelize.ENUM("0", "1", "2"),
      defaultValue: "1",
    },
    // 	购买票的数量
    ticketsNumber: {
      type: Sequelize.INTEGER,
      defaultValue: 0,
    },
    // 服务委托数量
    entrustedQuantityNumber: {
      type: Sequelize.INTEGER,
      defaultValue: 0,
    },
    // 	消费累计金额
    consumerPrices: {
      type: Sequelize.DECIMAL(10, 2),
      defaultValue: 0,
    },
    // 	消费累计金额
    disputeNumber: {
      type: Sequelize.INTEGER,
      defaultValue: 0,
    },
    //委托金额
    entrustedQuantityPrice: {
      type: Sequelize.DECIMAL(10, 2),
      defaultValue: 0,
    },
  },
  {
    timestamps: false,
    tableName: "Users",
  }
);

exports.UsersModel = UsersModel;
